<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/4
 * Time: 15:31
 */
include 'publics.php';
@header("content-Type: text/html; charset=utf-8");
//查询出留言数据
//$p_id = $_SESSION['t_id'];
$p_id = $_GET['p_id'];
$sql = "select * from table2 where p_id = $p_id";
//$sql = "select * from table2 where put_user_id = $p_id";
$mysql = new Mysql();
$date = $mysql -> select_one($sql);

$g_id = $date['get_user_id'];

$sqls = "select username from table1 where t_id = $p_id";
$p_arr = $mysql -> select_one($sqls);
$p_name = $p_arr['username'];

$sqla = "select username from table1 where t_id = $g_id";
$g_arr = $mysql -> select_one($sqla);
$g_name = $g_arr['username'];



    if (!empty($_POST)) {
        $txt = $_POST['txts'];
        //"update table2 set text = '".$txt."' where p_id = $p_id";
        $dsw = array(
            'text'=> $txt
        );
        $where = " p_id = $p_id";
        $dass = $mysql -> update($dsw,'table2',$where);
        if ($dass == true){
            jumps('修改成功',1,"message.php");
//            jumps('修改成功',1,"update.php");
        }else{
            jumps('修改失败',1,'message.php');
//            jumps('修改失败',1,"update.php");
        }
    }
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>修改</title>
</head>
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="utf8-php/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="utf8-php/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="utf8-php/lang/zh-cn/zh-cn.js"></script>
<style>
    .dj{
        float: left;
        border: 2px solid red;
        padding: 30px;
        margin: auto;
        position:absolute;
        left: 540px;
        right: 0;
        top: 700px;
        bottom: 0;
    }
    .dj span{
        display: block;
    }
    .dj span:nth-of-type(4){
        float: left;
    }
    .dj a:nth-of-type(1){
        float: right;
    }
</style>
<body>
    <h1 style="color: red;text-align: center;">请修改你的数据</h1>
    <div style="width: 1400px;display: inline-block;position: relative">
        <div class="dj" style="box-shadow: 10px 10px 10px #ccc;height: 400px;">
            <form action="" method="post">
                <span>发送人：<?php echo $p_name ?></span>
                <span>接收人：<?php echo $g_name ?></span>
                <span>时间：<?php echo date("Y-m-d H:i:s",$date['crete_time']); ?></span>
                <span>内容：</span>
                <br>
                <div class="ems">
                    <script id="editor" type="text/plain" name="txts"><?php echo $date['text']; ?></script>
                </div>
                <br>
<!--            <input type="hidden" value="--><?php // echo $p_id ?><!--" name="id">-->
                <input type="submit" value="确认修改"  onclick="return ims()" style="float: right;">
            </form>
        </div>
    </div>
</body>
<script type="text/javascript">
    var ue = UE.getEditor('editor');
    function ims() {
        var text =  UE.getEditor('editor').getContent();
        if (text == ''){
            alert('不能为空');
            return false;
        }
    }
</script>
</html>
</script>
</html>